<template>
	<page>
    <view class="head-info">
      <view class="head-card">
        <view class="bg">
          <image :src="info.avatar_pic"></image>
        </view>
        <view class="card" @click="onSetting">
          <view class="pic">
            <image :src="info.avatar_pic" mode="aspectFill"></image>
          </view>
          <view class="name-info">
            <view class="name">
              <text>{{info.nickname}}</text>
            </view>
            <view class="id-text">
              <text v-if="info.pid">ID:{{info.pid}}</text>
              <text v-else>登录/注册</text>
            </view>
          </view>
          <view class="more-code">
            <view class="code">
              <image src="/static/images/icon/ewm_Icon.png"></image>
            </view>
            <view class="more">
              <text class="right-arrows"></text>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="tool-item">
      <view class="item" @click="onWallet">
        <view class="title">
          <image src="/static/images/icon/qb_icon.png"></image>
          <text>钱包</text>
        </view>
        <view class="more">
          <text class="right-arrows"></text>
        </view>
      </view>
      <view class="item" @click="onSetting">
        <view class="title">
          <image src="/static/images/icon/sz_icon.png"></image>
          <text>设置</text>
        </view>
        <view class="more">
          <text class="right-arrows"></text>
        </view>
      </view>
    </view>
    <tab-bar selectStr="我的"></tab-bar>
	</page>
</template>

<script setup>
import TabBar from "../../components/TabBar/TabBar";
import {personalCenter} from "../../api/api";
import {getCurrentInstance, ref} from "vue";
import {onLoad, onShow} from "@dcloudio/uni-app";

const { proxy } = getCurrentInstance();
const info = ref({});


onLoad(() =>{

})
onShow(() =>{
  getData();
})
function getData(){
  proxy.$way.showLoading();
  personalCenter({
  }).then(res =>{
    proxy.$way.hideLoading();
    info.value = res.data;
    uni.setStorageSync('userInfo',res.data);
    proxy.$global.userInfo = res.data;
  }).catch(err =>{
    proxy.$way.hideLoading();
  })
}

/**
 * 设置点击
 */
function onSetting(){
  uni.navigateTo({
    url: '/pages/PersonalInfo/PersonalInfo'
  })
}

/**
 * 钱包点击
 */
function onWallet(){
  uni.navigateTo({
    url: '/view/mine/wallet/wallet'
  })
}
</script>

<style lang="scss">
  @import "my.scss";
</style>
